**********
* Replication code for Acheampong and Cann
* Assessing Public Trust in Ghana's Courts
* Journal of Law and Courts
**********

*In order to perform the replication, open the associated data file gha_r6_data.dta and then run this script

*******************
* Create Figure 1 *
*******************

tab Q52J  if Q52J >=0 & Q52J <7

set scheme s2mono

gr bar   if Q52J >=0 & Q52J <7, over(Q52J)

*********************
* Replicate Table 1 *
*********************

*Generage Age variable 
gen age = Q1 if Q1 <= 105

*Generate Education variable 
recode Q97 (0/2= 1) (3/9=0) (else=.), gen(e_noprim)
recode Q97 (0/2=0) (3/4=1) (5/9=0) (else=.), gen(e_prim)
recode Q97 (0/4=0) (5=1) (6/9=0) (else=.), gen(e_second)
recode Q97 (0/5=0) (6/9=1) (else=.), gen(e_postsec)

*Generate Gender Variable (1=female, 0=male)
recode Q101 (2=1) (1=0), gen(female)

*Generate Urban/Rural
recode Q115 (1=1) (2=0), gen(rural)

*Generate Party
gen NPP = 0
replace NPP = 1 if Q90B==262

gen NDC = 0
replace NDC = 1 if Q90B==261

gen othernopty = 0
replace othernopty = 1 if NPP==0 & NDC==0

*Generate Standard of Living
gen stdliv= Q4B if Q4B >0 & Q4B <7


*Generate Trust
gen trust = Q52J if Q52J >=0 & Q52J <7

*Generate Court Experience last 12 months
recode Q55L (-1=.) (0/3=1) (7=0) (9=.), gen(exp1yr)


*Estimate the Ordered Probit model
oprobit trust age i.e_prim i.e_second i.e_postsec i.exp1yr i.female i.NPP i.othernopty stdliv i.rural  
 
*Use Fitstat to get McKelvey-Zavoina r2 
fitstat

*Generate Average Marginal Effects/Discrete Changes
margins, dydx(*)
